<%@ page language="java" contentType="text/html; charset=UTF-8"%>

<%@ include file="../common/include/header.jsp" %>

<%@ page import="java.util.*,util.*" %>

<div>
<table border="0" cellpadding="0" cellspacing="0" width="980px">
	<tr>
		<td style="vertical-align: top;width: 180px;background: #fdb73a;">
			
<!-- Left Menu Including -->

<%@ include file="../common/include/leftmenu.jsp" %>

		</td>
		
		<td style="text-align: center;width: 800px;background: #ffffff; vertical-align: top;">
<!-- board view part -->
		<div id="freeMain" style="width: 800px;vertical-align: top;">

<table style="width: 800px;" border="0" cellpadding="0" cellspacing="0">

		<tr><td style="height: 150px;" colspan="2">
			<img src="<%=imagePath %>boardmain_01.jpg" border="0"/>
			</td>

			<td rowspan="4" style="background-image: url('<%=imagePath %>main_right.jpg');width:200px;"></td></tr>

	<tr><td style="width: 300px;height: 160px;vertical-align: top;">
			<table style="width: 290px;">
				<tr><td colspan="2" style="height: 20px;width: 260px;">
					<img src="<%=imagePath %>mainboard_01.jpg" border="1" onclick="javascript:getBoard('noticeboard.do?method=getList&cono=6&nbname=','공지사항');" onmouseover="javascript:this.style.cursor='hand';"/></td>
					<td style="width: 30px;"><a href="javascript:getBoard('noticeboard.do?method=getList&cono=6&nbname=','공지사항');">
					<img src="<%=imagePath %>icon_more.jpg" border="0"></a></td></tr>
			</table>
			<table style="border: 1px dotted #dddddd;width: 290px;">
				<tbody id="board"></tbody>
			</table></td>
			
		<td style="width: 300px;height: 160px;vertical-align: top;">
			<table style="width: 290px;">
				<tr><td colspan="2" style="height: 20px;width: 260px;">
					<img src="<%=imagePath %>mainboard_02.jpg" border="1" onclick="javascript:getBoard('noticeboard.do?method=getList&cono=8&nbname=','MYITEA 뉴스');" onmouseover="javascript:this.style.cursor='hand';"/></td>
					<td style="width: 30px;"><a href="javascript:getBoard('noticeboard.do?method=getList&cono=8&nbname=','MYITEA 뉴스');">
					<img src="<%=imagePath %>icon_more.jpg" border="0"></a></td></tr>
			</table>
			<table style="border: 1px dotted #dddddd;width: 290px;">
				<tbody id="board"></tbody>
			</table>
		</td>
		</tr>

	<tr><td style="width: 300px;height: 160px;vertical-align: top;">
			<table style="width: 290px;">
				<tr><td colspan="2" style="height: 20px;width: 260px;">
					<img src="<%=imagePath %>mainboard_03.jpg" border="1" onclick="javascript:getBoard('freeboard.do?method=getList&cono=5&fbname=','자유게시판');" onmouseover="javascript:this.style.cursor='hand';"/></td>
					<td style="width: 30px;"><a href="javascript:getBoard('freeboard.do?method=getList&cono=5&fbname=','자유게시판');">
					<img src="<%=imagePath %>icon_more.jpg" border="0"></a></td></tr>
			</table>
			<table style="border: 1px dotted #dddddd;width: 290px;">
				<tbody id="board"></tbody>
			</table></td>
			
		<td style="width: 300px;height: 160px;vertical-align: top;">
			<table style="width: 290px;">
				<tr><td colspan="2" style="height: 20px;width: 260px;">
					<img src="<%=imagePath %>mainboard_04.jpg" border="1" onclick="javascript:getBoard('qnaboard.do?method=list&qbname=','QnA');" onmouseover="javascript:this.style.cursor='hand';"/></td>
					<td style="width: 30px;"><a href="javascript:getBoard('qnaboard.do?method=list&qbname=','QnA');">
					<img src="<%=imagePath %>icon_more.jpg" border="0"></a></td></tr>
			</table>
			<table style="border: 1px dotted #dddddd;width: 290px;">
				<tbody id="board"></tbody>
			</table>
		</td></tr>
		
		<tr><td style="height: 20px;" colspan="2">
			</td></tr>

</table>

		</div>
		
		</td>		
	</tr>
</table>
</div>

<script type="text/javascript">
<!--
	window.attachEvent("onload",callBoards);
	
	var xmlHttp;
	
	function callBoards(){
		var url = "<%=path%>/board/menuajaxaction.do?method=boardmain";
		createXMLHttpRequest();
	    xmlHttp.onreadystatechange = handleStateChange;
	    xmlHttp.open("GET", url, true);
	    xmlHttp.send(null);
		
	}
		function createXMLHttpRequest() {
	    if (window.ActiveXObject) {
	        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    } 
	    else if (window.XMLHttpRequest) {
	        xmlHttp = new XMLHttpRequest();
	    }
	}
	
	function handleStateChange() {
	    if(xmlHttp.readyState == 4) {
	    	if(xmlHttp.status == 200){
	    		parseResponse();	       
			}	           
	    }
	}
	
	function parseResponse(){

		var xmlDoc = xmlHttp.responseXML;

		var notices = xmlDoc.getElementsByTagName('notices');

		for(var j=0;j<notices.length;j++){
			var notice = notices[j].getElementsByTagName('notice');
			var nTbody = board[j];
			for(var i=0;i<notice.length;i++){
				var no = notice[i].getElementsByTagName('nbno')[0].firstChild.nodeValue;
				var title = notice[i].getElementsByTagName('nbtitle')[0].firstChild.nodeValue;
				var date = notice[i].getElementsByTagName('nbdate')[0].firstChild.nodeValue;
				var cono = notice[i].getElementsByTagName('cono')[0].firstChild.nodeValue;
				var url = "noticeboard.do?method=detailView&cono="+cono+"&nbno=";
				nTbody.appendChild(createCell(no,title,date,url));		
			}
		}
			
		
		var datas = xmlDoc.getElementsByTagName('freeboard');
		
		var frees = datas[0].getElementsByTagName('free');
		var fTbody = board[2];
		for(var i=0;i<frees.length;i++){
			var no = frees[i].getElementsByTagName('fbno')[0].firstChild.nodeValue;
			var cono = frees[i].getElementsByTagName('cono')[0].firstChild.nodeValue;
			var title = frees[i].getElementsByTagName('fbtitle')[0].firstChild.nodeValue;
			var date = frees[i].getElementsByTagName('fbdate')[0].firstChild.nodeValue;
			var fbname = frees[i].getElementsByTagName('fbname')[0].firstChild.nodeValue;
			var url = "freeboard.do?method=detailView&cono="+cono+"&fbno="+no+"&fbname="+escape(encodeURIComponent(fbname));
			fTbody.appendChild(createCell(no,title,date,url));
		}
		
		var qnas = xmlDoc.getElementsByTagName('qna');
		var qTbody = board[3];
		for(var i=0;i<qnas.length;i++){
			var no = qnas[i].getElementsByTagName('qbno')[0].firstChild.nodeValue;
			var title = qnas[i].getElementsByTagName('qbtitle')[0].firstChild.nodeValue;
			var date = qnas[i].getElementsByTagName('qbdate')[0].firstChild.nodeValue;
			var url = "qnaboard.do?method=detailview&qbno=";
			qTbody.appendChild(createCell(no,title,date,url));
		}

		
		xmlHttp = null;
	}
	
	function createCell(no,title,date,url){
		var cell = document.createElement('tr');
		
		var _iconImage = document.createElement('td');
		_img = document.createElement('img');
		_img.src = "<%=imagePath %>icon_topmenu.jpg";
		_iconImage.appendChild(_img);
		
		var _title = document.createElement('td');
		
		var _link = document.createElement('a');
		_link.appendChild(document.createTextNode(title));
		_link.href = "<%=path%>/board/"+url+no;
		_title.appendChild(_link);
		_title.style.textAlign = "left";
		_title.style.width = "250";
		
		var _date = document.createElement('td');
		_date.appendChild(document.createTextNode("["+date.replace(/\-/g,"\/")+"]"));
		_date.style.fontSize = "8pt";
		
		cell.appendChild(_iconImage);
		cell.appendChild(_date);
		cell.appendChild(_title);
		
		cell.style.height = "20";
		
		
		return cell;
	}

	function getNotice(){
		location.href="<%=path %>/board/noticeboard.do?method=getList&cono=2";
	}
//-->
</script>

<%@ include file="../common/include/footer.jsp" %>
